package by.kniazhych.core.server.common {
	
	/**
	 * ...
	 * @author Boutylin Mikhail
	 */
	
	import by.vaukalak.core.commands.Command;
	
	public dynamic class ServerActionCommand extends Command {
		
		private var _commandIndex:uint;
		private var _flag:String;
		
		public function ServerActionCommand(name:String, commandIndex:uint, flag:String, args:Array = null) {
			super(name, args);
			_flag = flag;
			_commandIndex = commandIndex;
		}
		
		public function get commandIndex():uint { return _commandIndex; }
		
		public function get isFirstCommand():Boolean {
			return _flag == ServerActionFlag.FIRST_COMMAND || _flag == ServerActionFlag.UNIQUE_COMMAND;
		}
		
		public function get isLastCommand():Boolean {
			return _flag == ServerActionFlag.LAST_COMMAND || _flag == ServerActionFlag.UNIQUE_COMMAND;
		}
		
		public function becameFirst():void {
			if (_flag == ServerActionFlag.ORDINATED_COMMAND) _flag = ServerActionFlag.FIRST_COMMAND;
			if (_flag == ServerActionFlag.LAST_COMMAND) _flag = ServerActionFlag.UNIQUE_COMMAND;
		}
		
	}

}